package leetcode4;
import java.util.*;

public class Day10 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int k = in.nextInt();
            long[][] nums = new long[2][n];
            for(int i=0;i<n;i++) { //酸
                nums[0][i] = in.nextLong();
            }
            for(int i=0;i<n;i++) {//舔
                nums[1][i] = in.nextLong();
            }
            //
//            PriorityQueue<Map<Integer,Integer>> queue = new PriorityQueue<>(); //存储k个下标
            PriorityQueue<long[]> queue = new PriorityQueue<>((a,b)->{
                return (int)(a[0]-b[0]);
            });
            for(int i = 0;i < n;i++) {
                if(queue.size()<k) {
                    long[] t = new long[2];
                    t[0] = nums[1][i]-nums[0][i];
                    t[1] = i;
                    queue.add(t);
                }else {
                    long[] top = queue.peek();
                    long val = nums[1][i]-nums[0][i];
                    if(val > top[0]) {
                        queue.poll();
                        queue.add(new long[]{val,i});
                    }
                }
            }
            long a=0,b=0;
            while (!queue.isEmpty()) {
                long[] top = queue.poll();
                long index = top[1];
                a += nums[0][(int)index];
                b += nums[1][(int)index];
            }
            System.out.println(a + " "+ b);
        }
    }
}
